package com.damai.pay.wx;

import java.text.ParseException;
import java.util.Date;
import java.util.Map;

import com.citywithincity.pay.PayType;
import com.citywithincity.utils.DateTimeUtil;
import com.damai.pay.PayInfo;

public class WXPayInfo implements PayInfo {
	
	private Map<String, String> data;
	
	
	public WXPayInfo(Map<String, String> map) {
		data = map;
	}
	
	/**
	 * 
	 */
	@Override
	public int getRealFee() {
		return Integer.parseInt(data.get(WXPayModel.cash_fee));
	}
	
	/**
	 * 
	 */
	@Override
	public int getFee() {
		return Integer.parseInt(data.get(WXPayModel.cash_fee));
	}


	@Override
	public boolean isPaySuccess() {
		String status = data.get(WXPayModel.trade_state);
		return status.equals(WXPayModel.SUCCESS);
	}

	@Override
	public boolean isRefund() {
		String status = data.get(WXPayModel.trade_state);
		return status.equals(WXPayModel.REFUND);
	}
	
	/**
	 * 
	 */
	@Override
	public String getOutId() {
		return data.get(WXPayModel.out_trade_no);
	}

	/**
	 * 
	 */
	@Override
	public String getPlatId() {
		return data.get(WXPayModel.transaction_id);
	}

	@Override
	public Date getDate() {
		try {
			return DateTimeUtil.parseShortDateTime(data.get(WXPayModel.time_end));
		} catch (ParseException e) {
			return new Date();
		}
	}

	@Override
	public int getType() {
		return PayType.PayType_WX;
	}

	@Override
	public Object getExtra() {
		return null;
	}

	
	

	

}
